#include "network.hpp"


namespace rocket 
{
network::network(int port,string ip)
{
    _network_address=sockaddr_in{AF_INET,htons(port), in_addr{inet_addr(ip.c_str())}};
}
network::network(sockaddr_in addr)
{
    _network_address=addr;
}
network::~network()
{

}


int network::get_port()
{
    return ntohs( _network_address.sin_port);
}

string network::get_ip()
{
    return string(inet_ntoa(_network_address.sin_addr));
}

sockaddr *network::get_pointer()
{
    return (sockaddr *)&_network_address;
}

int network::get_size()
{
    return sizeof(_network_address);
}


}//end of namespace rocket